﻿CREATE TABLE [dbo].[Entities] (
    [EntityID]      INT            IDENTITY (100200, 1) NOT NULL,
    [EntityType]    NVARCHAR (100) NOT NULL,
    [EntitySubType] NVARCHAR (100) NULL,
    [EntityName]    NVARCHAR (255) NULL,
    [LookupName]    NVARCHAR (MAX) NULL,
    CONSTRAINT [PK_Entity] PRIMARY KEY CLUSTERED ([EntityID] ASC),
    CONSTRAINT [FK_Entity_DefinedEntitySubTypes] FOREIGN KEY ([EntityType], [EntitySubType]) REFERENCES [dbo].[DefinedEntitySubTypes] ([EntityType], [EntitySubType]),
    CONSTRAINT [FK_Entity_EntityTypes] FOREIGN KEY ([EntityType]) REFERENCES [dbo].[DefinedEntityTypes] ([EntityType]) ON UPDATE CASCADE
);



